﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using JM.JCY.BusinessEntity;
using JM.JCY.Proxy;
using NCS.IConnect.ApplicationContexts;
using JM.JCY.Common;
using JM.JCY.Common.Utilities;
using Microsoft.SharePoint;

namespace JM.JCY.SharePointComponent.LawArchives.CreateLawCaseSafety
{
    public partial class CreateLawCaseSafetyUserControl : UserControl
    {
        public string _userName
        {
            set { ViewState["_userName"] = value; }
            get { return (string)ViewState["_userName"]; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (ApplicationContext.Current.UserName != null)
            {
                _userName = ApplicationContext.Current.UserName;
            }

            if (!IsPostBack)
            {
                //this.dtFillDate.SelectedDate = DateTime.Now.Date;
                //this.txtCaseFiller.Text = _userName;
            }

        }

        protected void imgSubmit_Click(object sender, ImageClickEventArgs e)
        {
            using (LawCaseProxy proxy = new LawCaseProxy())
            {
                var newDT = new LawCaseDataSet.T_SelfOperateDataTable();
                var newCaseRow = newDT.NewT_SelfOperateRow();

                newCaseRow.CaseName = this.txtCaseName.Text;
                newCaseRow.CaseInitial = this.txtCaseInitial.Text;
                newCaseRow.CaseFiller = this.txtCaseFiller.Text;
                newCaseRow.FillDate = this.dtFillDate.SelectedDate;
                newCaseRow.CaseOperator = this.txtCaseOperator.Text;

                newCaseRow.Case_1 = this.rbCase1.SelectedValue;
                newCaseRow.Case_2 = this.rbCase2.SelectedValue;
                newCaseRow.Case_3 = this.rbCase3.SelectedValue;
                newCaseRow.Case_4 = this.rbCase4.SelectedValue;
                newCaseRow.Case_5 = this.rbCase5.SelectedValue;
                newCaseRow.Case_6 = this.rbCase6.SelectedValue;
                newCaseRow.Case_7 = this.rbCase1.SelectedValue;
                newCaseRow.Case_8 = this.rbCase8.SelectedValue;
                newCaseRow.Case_9 = this.rbCase9.SelectedValue;
                newCaseRow.Case_10 = this.rbCase10.SelectedValue;

                newCaseRow.Remark_1 = this.txtRemark1.Text;
                newCaseRow.Remark_2 = this.txtRemark2.Text;
                newCaseRow.Remark_3 = this.txtRemark3.Text;
                newCaseRow.Remark_4 = this.txtRemark4.Text;
                newCaseRow.Remark_5 = this.txtRemark5.Text;
                newCaseRow.Remark_6 = this.txtRemark6.Text;
                newCaseRow.Remark_7 = this.txtRemark7.Text;
                newCaseRow.Remark_8 = this.txtRemark8.Text;
                newCaseRow.Remark_9 = this.txtRemark9.Text;
                newCaseRow.Remark_10 = this.txtRemark10.Text;

                JCYUtility.UpdateCommonFields(newCaseRow, "Iori");
                newDT.AddT_SelfOperateRow(newCaseRow);
                proxy.UpdateSelfOperate(newDT);

                Response.Redirect("LawCaseSafety.aspx");
            }


        }

        protected void imgCancel_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("LawCaseSafety.aspx");
        }
    }
}
